package com.hyt.it.ogt.kq.service.gov.examsystem;

import com.hyt.it.ogt.kq.common.gov.constant.examsys.TypeEnum;
import com.hyt.it.ogt.kq.service.gov.examsystem.implement.GceImplement;
import com.hyt.it.ogt.kq.service.gov.examsystem.implement.ObtImplement;
import com.hyt.it.ogt.kq.common.config.exception.KqException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * <p>
 * 考试系统工厂
 * </p>
 *
 * @author huangyh
 * @since 2021-07-19
 */
@Slf4j
@Component
public class ExamSystemFactory {

    @Resource
    protected GceImplement gceImplement;

    @Resource
    protected ObtImplement obtImplement;

    public ExamSystem getExamSystem(String examSystemType) throws KqException {
        ExamSystem examSystem;
        switch (TypeEnum.getType(examSystemType)) {
            case GCE:
                examSystem = gceImplement;
                break;
            case OBT:
                examSystem = obtImplement;
                break;
            default:
                throw new KqException(-1, "考试系统类型不存在");
        }
        return examSystem;
    }

    public ExamSystemFactory() {

    }

}
